package cc.wsyw126.java.stream;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created by junpeng.yang on 16/8/24.
 */
public class Match {
    public static void main(String[] args) throws FileNotFoundException {
        BufferedReader bf = new BufferedReader(new FileReader("/Users/yangdp/Desktop/Java8StreamTest.txt"));
        List<String> list =  bf.lines().flatMap(line -> Stream.of(line.split(" "))).filter(word -> word.contains("a")).collect(Collectors.toList());
        list.forEach(System.out::println);
        boolean b=  bf.lines().flatMap(line -> Stream.of(line.split(" "))).allMatch(word -> word.contains("a"));
        System.out.println("all Child? " + b);

        System.out.println("-----------");
        boolean b1=  bf.lines().flatMap(line -> Stream.of(line.split(" "))).anyMatch(word -> word.contains("a"));
        System.out.println("any Child? " + b1);

    }
}
